import {jwtDecode} from "jwt-decode";

let jwtKey = "jwt";

//保存jwt()
function saveJwt(jwt) {
    sessionStorage.setItem(jwtKey, jwt);
}

//获取jwt
function getJwt() {
    return sessionStorage.getItem(jwtKey);
}

//删除jwt
function removeJwt() {
    sessionStorage.removeItem(jwtKey);
}

//解析jwt
function decodeJwt() {
    const jwt = getJwt();
    return jwtDecode(jwt);
}

export {saveJwt, getJwt, removeJwt, decodeJwt}